{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Note:** The \\\"default_backcast\\\" parameter must be set to false *during basket creation* in order to upload custom position history after the basket has been published to Marquee."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from datetime import date\n",
    "from gs_quant.markets.baskets import Basket\n",
    "from gs_quant.markets.position_set import Position, PositionSet\n",
    "from gs_quant.session import Environment, GsSession"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "client = 'CLIENT ID'\n",
    "secret = 'CLIENT SECRET'\n",
    "\n",
    "GsSession.use(Environment.PROD, client_id=client, client_secret=secret, scopes=('read_product_data read_user_profile',))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "basket = Basket.get('GSMBXXXX')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\"Below is a simplied example on how to create position sets. You may refer to the position set examples in this directory for more options on how to upload larger/more complicated position sets.\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "positions = [Position(identifier='AAPL UW', weight=0.5), Position(identifier='MSFT UW', weight=0.5)]\n",
    "\n",
    "pos_set_1 = PositionSet(positions, date(2019, 6, 3))\n",
    "pos_set_2 = PositionSet(positions, date(2020, 1, 2))\n",
    "pos_set_3 = PositionSet(positions, date(2020, 6, 1))\n",
    "pos_set_4 = PositionSet(positions, date(2021, 1, 4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "basket.upload_position_history([pos_set_1, pos_set_2, pos_set_3, pos_set_4])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
